package com.agile.leetcode.hutool.http;

import cn.hutool.http.HttpUtil;

import java.util.Random;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * @Author:ChenZhangKun
 * @Date: 2023/11/12 20:23
 */
public class HttpClient {
    public static void main(String[] args) throws Exception {
        CountDownLatch countDownLatch = new CountDownLatch(20);
        ExecutorService executorService = Executors.newFixedThreadPool(20);
        for (int i = 0; i < 20; i++) {
            executorService.execute(() -> {
                try {
                    countDownLatch.await();
                    send(new Random().nextInt(3));
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            });
            countDownLatch.countDown();
        }
        Thread.currentThread().join();
    }

    public static void send(Integer number) {
        System.out.println(HttpUtil.get("http://localhost:8083/czk/hysitrix/query/"+number+""));
    }
}
